package com.lwj.springbootvue.controller;

import java.util.List;

import com.lwj.springbootvue.model.Classe;
import com.lwj.springbootvue.response.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.lwj.springbootvue.service.IClasseService;


/**
 * 班级Controller
 * 
 * @author king
 * @date 2024-12-25
 */

@RestController
@RequestMapping("/classe")
public class ClasseController
{
    @Autowired
    private IClasseService classeService;



    /**
     * 查询班级总人数
     *
     * @param
     * @return 班级
     */
    @GetMapping("/updateClasseNumByScid")
    public Result updateClasseNumByScid(){
        int i = classeService.updateClasseNumByScid();
        return Result.success("更新班级总人数成功！");
    };


    /**
     * 查询班级列表
     */
    @GetMapping("/list")
    public Result list(Classe classe)
    {
        List<Classe> list = classeService.selectClasseList(classe);
        return Result.success(list);
    }



    /**
     * 获取班级详细信息
     */
    @GetMapping(value = "/{cid}")
    public Result getInfo(@PathVariable("cid") Long cid)
    {
        return Result.success(classeService.selectClasseByCid(cid));
    }

    /**
     * 新增班级
     */

    @PostMapping
    public Result add(@RequestBody Classe classe)
    {
        return Result.success(classeService.insertClasse(classe));
    }

    /**
     * 修改班级
     */
    @PutMapping
    public Result edit(@RequestBody Classe classe)
    {
        return Result.success((classeService.updateClasse(classe)));
    }

    /**
     * 删除班级
     */
	@DeleteMapping("/{cids}")
    public Result remove(@PathVariable Long[] cids)
    {
        return Result.success((classeService.deleteClasseByCids(cids)));
    }
}
